//
//  MainPageViewController.m
//  zhongjianProject
//
//  Created by Farben on 2020/4/15.
//  Copyright © 2020 Farben. All rights reserved.
//

#import "MainPageViewController.h"
#import "HomeMarketViewController.h"
#import "HomeMessageViewController.h"
#import "HomePageTabView.h"
#import "Header.h"
@interface MainPageViewController ()<XXPageTabViewDelegate>
@property (nonatomic) HomePageTabView *pageTabView;
@end

@implementation MainPageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self setupSegmentType];
    //用于消除资讯详情页因设置导航栏不透明导致的向下偏移问题
    self.extendedLayoutIncludesOpaqueBars = YES;
    
    
    
    [self setNavigationBarTitleColor:[UIColor whiteColor]];
    
    
}
- (void)setupSegmentType{
    //行情
    HomeMarketViewController *market = [[HomeMarketViewController alloc] init];
    market.view.backgroundColor = [UIColor cyanColor];
    //资讯
    HomeMessageViewController *message = [[HomeMessageViewController alloc] init];
    message.view.backgroundColor = [UIColor yellowColor];
    [self addChildViewController:market];
    [self addChildViewController:message];
    _pageTabView = [[HomePageTabView alloc] initWithChildControllers:self.childViewControllers childTitles:@[@"行情", @"资讯"]];
    _pageTabView.frame = CGRectMake(0, NAVIGATION_BAR_HEIGHT, kScreen_WIDTH, kScreen_HEIGHT-NAVIGATION_BAR_HEIGHT);
    _pageTabView.tabSize = CGSizeMake(kScreen_WIDTH, 44);
//    _pageTabView.tabItemFont = AppFont(15);
//    _pageTabView.unSelectedColor = AppHTMLColor(@"999999");
//    _pageTabView.selectedColor = AppHTMLColor(@"4bccbc");
    _pageTabView.bodyBounces = NO;
    _pageTabView.titleStyle = XXPageTabTitleStyleDefault;
    _pageTabView.indicatorStyle = XXPageTabIndicatorStyleFollowText;
    _pageTabView.delegate = self;
    [self.view addSubview:_pageTabView];
    
}
#pragma mark - XXPageTabViewDelegate
- (void)pageTabViewDidEndChange {
    NSInteger selectedTabIndex = _pageTabView.selectedTabIndex;
    NSLog(@"点击了index：%zd", selectedTabIndex);

    switch (selectedTabIndex) {
        case 0:
        {
            // 我的好友
        }
            break;
        case 1:
        {
            // 通讯录
        }
            break;
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
